﻿
@page
@model AdminUI.Pages.Mall.GoodsAddModel
@{
    var F = Html.F();
}

@section body{

    <f:Form ID="Form1" ShowBorder="false" ShowHeader="false" AutoScroll="true" BodyPadding="15" IsViewPort="true">
        <Rows>
            <f:FormRow ColumnWidths="100%">
                <Items>
                    <f:TextBox ID="GoodsName" Required="true" Label="商品名称" EmptyText="请输入商品名称" ShowRedStar="true"></f:TextBox>
                </Items>
            </f:FormRow>
            <f:FormRow ColumnWidths="100%">
                <Items>
                    <f:FileUpload ID="ImageUrl" Label="商品主图" EmptyText="请选择商品主图" AcceptFileTypes="image/*" ButtonIcon="Add"></f:FileUpload>
                </Items>
            </f:FormRow>
            <f:FormRow ColumnWidths="50% 50%">
                <Items>
                    <f:DropDownList ID="CategoryID" Label="选择类别" DataValueField="CategoryID" DataTextField="CategoryName" SelectedValue="0" DataSource="@ViewBag.Categories"></f:DropDownList>
                    <f:RadioButtonList ID="Status" Label="状态" SelectedValue="1">
                        <f:RadioItem Text="暂不上架" Value="0" />
                        <f:RadioItem Text="上架销售" Value="1" />
                    </f:RadioButtonList>
                </Items>
            </f:FormRow>
            <f:FormRow ColumnWidths="50% 50%">
                <Items>
                    <f:NumberBox ID="CostPrice" Label="成本价" EmptyText="" Text="0.00" MaxValue="999999" MinValue="0" NoDecimal="false" ShowTrigger="false"></f:NumberBox>
                    <f:NumberBox ID="MarketPrice" Label="市场价" EmptyText="" Text="0.00" MaxValue="999999" MinValue="0" NoDecimal="false" ShowTrigger="false"></f:NumberBox>
                </Items>
            </f:FormRow>
            <f:FormRow ColumnWidths="75% 25%">
                <Items>
                    <f:RadioButtonList ID="IsSpecial" Label="特价设置" SelectedValue="" OnSelectedIndexChanged="@Url.Handler("RBL_SelectedIndexChanged")" OnSelectedIndexChangedParameter1="@(new Parameter("selected", "this.getValue()"))">
                        <f:RadioItem Text="不设置" Value="false" />
                        <f:RadioItem Text="设置各级别价格和业绩提成" Value="true" />
                    </f:RadioButtonList>
                    <f:NumberBox ID="SortFlag" Label="排序" EmptyText="" Text="0" MinValue="0" ShowTrigger="true"></f:NumberBox>
                </Items>
            </f:FormRow>
            <f:FormRow ColumnWidths="50% 50%">
                <Items>
                    <f:NumberBox ID="MAPrice" Label="A级会员价" MaxValue="999999" Text="0.00" MinValue="0" NoDecimal="false" ShowTrigger="false" Enabled="false"></f:NumberBox>
                    <f:NumberBox ID="MBPrice" Label="B级会员价" MaxValue="999999" Text="0.00" MinValue="0" NoDecimal="false" ShowTrigger="false" Enabled="false"></f:NumberBox>
                </Items>
            </f:FormRow>
            <f:FormRow ColumnWidths="50% 50%">
                <Items>
                    <f:NumberBox ID="MCPrice" Label="C级会员价" MaxValue="999999" Text="0.00" MinValue="0" NoDecimal="false" ShowTrigger="false" Enabled="false"></f:NumberBox>
                    <f:NumberBox ID="Commission" Label="业绩提成" MaxValue="999999" Text="0.00" MinValue="0" NoDecimal="false" ShowTrigger="false" Enabled="false"></f:NumberBox>
                </Items>
            </f:FormRow>
            <f:FormRow ColumnWidths="100%">
                <Items>
                    <f:CheckBoxList ID="SalesRange" Label="销售范围">
                        <f:CheckItem Text="A级会员" Value="1" Selected="true" />
                        <f:CheckItem Text="B级会员" Value="2" Selected="true" />
                        <f:CheckItem Text="C级会员" Value="4" Selected="true" />
                    </f:CheckBoxList>
                </Items>
            </f:FormRow>
        </Rows>
        <Toolbars>
            <f:Toolbar ID="Toolbar1" Position="Top" ToolbarAlign="Left">
                <Items>
                    <f:Button ID="btnClose" Text="关闭" Icon="Cross" IconFont="Close" OnClientClick="F.activeWindow.hide();"></f:Button>
                    <f:Button ID="btnReset" Text="重置" Icon="ArrowUndo" OnClientClick="F.ui.Form1.reset();"></f:Button>
                    <f:Button ID="btnSubmit" Text="保存" Icon="SystemSave" OnClick="@Url.Handler("btnSubmit_Click")" _ValidateForms="Form1" OnClickFields="Form1"></f:Button>

                </Items>
            </f:Toolbar>
        </Toolbars>
    </f:Form>

    <f:Window ID="Window1" IsModal="true" Hidden="true" Target="Top" EnableResize="true" EnableMaximize="true" EnableIFrame="true" Width="400" Height="500">
        <Listeners>
            <f:Listener Event="close" Handler="onWindowClose('refresh');"></f:Listener>
        </Listeners>
    </f:Window>

}
@section head{
    <link href="https://cdn.bootcdn.net/ajax/libs/wangeditor5/5.1.23/css/style.min.css" rel="stylesheet">
    <style>
        #editor—wrapper {
            border: 1px solid #ccc;
            z-index: 100; /* 按需定义 */
        }

        #toolbar-container {
            border-bottom: 1px solid #ccc;
        }

        #editor-container {
            height: 500px;
        }
    </style>
}
@section script {
    @* <script src="https://cdn.bootcdn.net/ajax/libs/wangeditor5/5.1.23/index.min.js"></script> *@
    <script>
        F.ready(function () {
            // const { createEditor, createToolbar } = window.wangEditor

            // const editorConfig = {
            //     placeholder: '请输入内容...',
            //     MENU_CONF: {},
            //     onChange(editor) {
            //         const html = editor.getHtml()
            //         F.ui.Memo.setValue(html);
            //     }
            // }

            // editorConfig.MENU_CONF['uploadImage'] = {
            //     server: '/api/upload/uploadimage',
            //     timeout: 10 * 1000, // 10s
            //     fieldName: 'upfile',
            //     maxFileSize: 5 * 1024 * 1024, // 5M
            //     base64LimitSize: 5 * 1024, // 如果图片尺寸小于5KB，那么转换为base64格式插入

            //     onFailed(file, res) {
            //         alert(res.message)
            //         console.log('onFailed', file, res)
            //     },
            //     onError(file, err, res) {
            //         alert(err.message)
            //         console.error('onError', file, err, res)
            //     },
            // }

            // editorConfig.MENU_CONF['uploadVideo'] = {
            //     server: '/api/upload/uploadvideo',
            //     timeout: 10 * 1000, // 10s
            //     fieldName: 'upfile',
            //     maxFileSize: 10 * 1024 * 1024, // 10M

            //     onFailed(file, res) {
            //         alert(res.message)
            //         console.log('onFailed', file, res)
            //     },
            //     onError(file, err, res) {
            //         alert(err.message)
            //         console.error('onError', file, err, res)
            //     },
            // }

            // const editor = createEditor({
            //     selector: '#editor-container',
            //     html: '<p><br></p>',
            //     config: editorConfig,
            //     mode: 'default', // or 'simple'
            // })

            // const toolbarConfig = {}

            // const toolbar = createToolbar({
            //     editor,
            //     selector: '#toolbar-container',
            //     config: toolbarConfig,
            //     mode: 'default', // or 'simple'
            // })
        })

        function onSelectAccount(event) {
            var id = F.ui.AccountID.getValue();
            var path = "/Dialog/SelectAccount?t=1&id="+id;
            F.ui.Window1.show(path, '选择供应商', 800, 500);
        }

        function updateAccountSelectValue(id, text) {
            F.ui.AccountName.setText(text);
            F.ui.AccountID.setValue(id);
        }

        function onSelectTenant(event) {
            var path = "/Dialog/SelectTenant";
            //alert(path);
            F.ui.Window1.show(path, '选择租户', 700, 500);
        }

        function updateTenantSelectValue(id, text) {
            F.ui.TName.setText(id + '-' + text);
            F.ui.TID.setValue(id);

            F.doPostBack('@Url.Handler("TID_Changed")', {
                tid: id
            });
        }
    </script>
}
